zz_

src/max.js

zzmq.dev@gmail.com[dev1]/mathkit[add-lcm-b-function-returns-least-common] / src / max.js @ c510a748 Download
Ladder Summary
  • file Exports a `max` function that accepts any number of numeric arguments and returns the greatest value by delegating directly to the native `Math.max`. This implementation inherently supports the full `Math.max` semantics, including returning `-Infinity` when called with no arguments, propagating `NaN` if any argument is `NaN`, and correctly handling `Infinity` values.
 /**
  * Returns the maximum number from the provided arguments.
  * Mirrors the behavior of the built‑in Math.max:
  * - Returns -Infinity when called with no arguments.
  * - Returns NaN if any argument is NaN.
  *
  * @param {...number} numbers - A list of numbers to evaluate.
  * @returns {number} The greatest number, or -Infinity / NaN per Math.max semantics.
  */
 export function max(...numbers) {
  // Delegating to the native Math.max ensures correct handling of edge cases
  // such as NaN propagation and Infinity handling.
  return Math.max(...numbers);
 }